//
//  TitleSectionController.swift
//  FeastBooking
//
//  Created by Imon on 2017/9/3.
//  Copyright © 2017年 Imon. All rights reserved.
//

import UIKit
import IGListKit

class TitleSectionController: ListSectionController {
    
    private var object: Title?
    private let titleHeight: CGFloat = 30
    
    override init() {
        super.init()
        inset = UIEdgeInsets(top: 5, left: 0, bottom: 0, right: 0)
    }
    
    override func sizeForItem(at index: Int) -> CGSize {
        let width = collectionContext!.containerSize.width
        return CGSize(width: width, height: titleHeight)
    }
    
    override func cellForItem(at index: Int) -> UICollectionViewCell {
        guard  let cell = collectionContext?.dequeueReusableCell(of: TitleCell.self, for: self, at: index) as? TitleCell else {
            fatalError()
        }
        cell.text = object?.value
        return cell
    }
    
    override func didUpdate(to object: Any) {
        self.object = object as? Title
    }
}
